﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;
using Microsoft.Practices.EnterpriseLibrary.Validation;

namespace WebPattern.Core.Validators
{
    [HasSelfValidation]
    class PatternUsingValidators
    {
        #region Properties
        [
         ContainsCharactersValidator("")
        , DomainValidator()
            // ...
        ]
        public string PrString { set; get; }
        #endregion

        #region Members
        [SelfValidation]
        internal void OnValidate(ValidationResults results)
        {
            if (true)
                results.AddResult(new ValidationResult(
                         message: "Invalid gender type for legal person entity (juridical persons don't have sex :D, please set Gender value to NotApplicable)",
                         target: this,
                         key: string.Empty,
                         tag: string.Empty,
                         validator: null
                    ));

            if (true)
            {
                new EmailValidator();

                new NotNullOrNotWhiteSpaceValidator("not valid template message").DoValidate(this.PrString, this, "AppName", results);

                new MaxMinLengthValidator(1).DoValidate(this.PrString, this, "appName", results);
            }
        }
        #endregion
    }
}
